﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GomeeSoft.src.control
{
    public partial class UCTextBox : UserControl
    {
        [System.ComponentModel.Browsable(true)]
        public override string Text
        {
            get
            {
                return textBox1.Text;
            }
            set
            {
                textBox1.Text = value;
                Invalidate();
            }
        }
        public bool IsPassword
        {
            get
            {
                if (textBox1.PasswordChar == '*')
                    return true;
                else
                    return false;
            }
            set
            {
                if (value)
                    textBox1.PasswordChar = '*';
                else
                    textBox1.PasswordChar = (char)0;
                Invalidate();
            }
        }
        public UCTextBox()
        {
            InitializeComponent();
            textBox1.Location = new Point(3, 2);
            textBox1.BorderStyle = BorderStyle.None;
        }

        private void UCTextBox_Paint(object sender, PaintEventArgs e)
        {
            Pen pen = new Pen(Color.FromArgb(102, 137, 206));
            Graphics graphics = e.Graphics;
            graphics.DrawLine(pen, 0, 0, 0, Height - 1);
            graphics.DrawLine(pen, Width - 1, Height - 1, 0, Height - 1);
            graphics.DrawLine(pen, Width - 1, Height - 1, Width - 1, 0);
            graphics.DrawLine(pen, 0, 0, Width - 1, 0);
            pen.Dispose();
        }

        private void UCTextBox_Resize(object sender, EventArgs e)
        {
            textBox1.Width = Width - 6;
            textBox1.Height = Height - 4;
        }
    }
}
